<?php
$apiKey = '';
$prompt = $_POST['username'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.tripo3d.ai/v2/openapi/task');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    "Authorization: Bearer {$apiKey}"
]);
$data = [
    "type" => "text_to_model",
    "prompt" => $prompt
];
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
if ($response === false) {
    echo 'Curl error: '. curl_error($ch);
} else {
    $task = json_decode($response)->data->task_id;
    header("Location: 3ds3.php?task=".$task);
}
curl_close($ch);
?>
